/*
 * @Author: Leo.wang wanglizhigs@163.com
 * @Date: 2024-06-18 22:37:20
 * @LastEditors: Leo.wang wanglizhigs@163.com
 * @LastEditTime: 2024-06-18 23:09:45
 * @FilePath: /chat-ai-plus/src/verify.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { nextTick, onBeforeMount, getCurrentInstance } from 'vue';
const { VITE_STORAGE_TOKEN } = import.meta.env;
import { isMobile } from '@/utils/common';
import popup from '@/components/PopupLogin/index';
import { local, session } from '@/service/storage.service';
export function useVerify() {
  const instance = getCurrentInstance();
  onBeforeMount(() => {
    const token = local.get(VITE_STORAGE_TOKEN);
    if (!token) {
      uni.reLaunch({
        url: '/pages/login/index',
      });
      // if (isMobile()) {
      //   uni.navigateTo({
      //     url: '/pages/login/index',
      //   });
      // } else {
      //   nextTick(() => {
      //     popup.open(instance);
      //   })
      // }
    }
  });
}
